<template>
  <!-- 周期执行 -->
  <div class="crontabdom">
    <div class="crontabdom-con">
      <el-form ref="elForm3" :model="formData3" :rules="rules3" size="medium" label-width="150px">
        <!-- 例行巡检和自定义巡检下，显示执行模式 -->
        <el-row>
          <el-col :span="24">
            <el-form-item label="执行模式：" prop="zxms">
              <el-radio-group v-model="formData3.zxms">
                <el-radio label="1" name="1">间隔模式</el-radio>
                <!-- <el-radio label="2" name="2">周模式</el-radio> -->
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 周期执行-间隔模式，显示 -->
        <el-row v-if="formData3.zxms==1">
          <el-col :span="24">
            <el-form-item label="执行日期：" prop="zxrq">
              <el-date-picker v-model="formData3.zxrq" type="datetime" placeholder="选择日期"></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 周期执行-间隔模式，才显示 -->
        <el-row v-if="formData3.zxms==1">
          <el-col :span="24">
            <el-form-item label="执行周期：" prop="zxzq">
              <el-input-number
                v-model="formData3.zxzq"
                controls-position="right"
                :min="0"
                :max="100"
              ></el-input-number>
              <span>天</span>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 只有周期执行-周模式，才显示 -->
        <!-- <el-row :gutter="15" v-if="formData3.zxms==2">
          <el-col :span="24">
            <el-form-item label="星期选择：" prop="zqweek">
              <el-checkbox-group v-model="formData3.zqweek">
                <el-checkbox label="2">周一</el-checkbox>
                <el-checkbox label="3">周二</el-checkbox>
                <el-checkbox label="4">周三</el-checkbox>
                <el-checkbox label="5">周四</el-checkbox>
                <el-checkbox label="6">周五</el-checkbox>
                <el-checkbox label="7">周六</el-checkbox>
                <el-checkbox label="1">周日</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
        </el-row>-->
      </el-form>
    </div>
    <div class="task-newAddm-btn">
      <el-button type="primary" @click="next" class="centerbox">任务下发</el-button>
    </div>
  </div>
</template>

<script lang="ts">
import { Component, Vue, Prop } from "vue-property-decorator";
import date from "@/utils/date";
@Component
export default class crontabdom extends Vue {
  @Prop() datas!: any[];
  public formData3 = {
    zxfs: 0,
    zxrq: "",
    zxzq: "",
    zxms: 0,
    zqweek: [], //传参的时候用-拼接
  };
  public rules3 = {
    zxfs: [],
    zxrq: [],
    zxzq: [],
    zxms: [],
    zqweek: [],
  };
  // 周期执行的下发
  next() {
    console.log(this.datas);

    if (this.formData3.zxrq) {
      let xjlx = this.datas[0].XJLX;
      let BDZID = this.datas[0].BDZID;
      let RWID = this.datas[0].ID;
      let ZXQKID = this.datas[0].ZXQKID;
      let xszq = date(this.formData3.zxrq) + "," + this.formData3.zxzq;
      let params = {
        czzt: "zq",
        bdzid: BDZID,
        rwid: RWID,
        xjlx: xjlx,
        xszq: xszq,
        zxqkid: ZXQKID,
        sendType: "zq",
      };

      (this as any).$services
        .xzrwRwxfButton({
          data: { xzrwParam: params },
          method: "post",
          postparams: true,
        })
        .then((result: any) => {
          if (result.data) {
            this.$message({
              type: "success",
              message: "下发成功!",
            });
            this.$emit("close");
          }
        })
        .catch((err: object) => {
          console.log(err);
          this.$message({
            type: "warning",
            message: "下发失败!",
          });
        });
    } else {
      this.$message({
        type: "warning",
        message: "请选择日期",
      });
    }
  }
}
</script>

<style lang="scss" scoped>
.crontabdom {
  width: 100%;
  height: 450px;

  .task-newAddm-btn {
    width: 100%;
    display: flex;
    justify-content: flex-end;
  }
  &-item {
    display: flex;
    justify-content: center;
    margin: 0.2rem 0;
    > div {
      line-height: 0.38rem;
      &:nth-child(3) {
        display: flex;
        justify-content: space-around;
        align-items: center;
        width: 1rem;
        .iconfont {
          font-size: 0.24rem;
          cursor: pointer;
        }
      }
    }
    > div:first-child {
      width: 1rem;
    }
  }
  &-con {
    height: 400px;
    overflow-y: auto;
  }
}
</style>

